package com.muyi.biling.fragment;

import android.support.v4.app.Fragment;

import com.dothantech.lpapi.LPAPI;
import com.dothantech.printer.IDzPrinter;
import com.github.lzyzsd.jsbridge.BridgeWebView;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.FragmentArg;
import org.androidannotations.annotations.ViewById;

import com.muyi.biling.R;
import com.muyi.biling.web.WebViewManager;

/**
 * Created by developer on 18-2-7.
 */

@EFragment(R.layout.frag_general_web)
public class GeneralWebFragment extends Fragment {

    @ViewById(R.id.frag_general_web)
    BridgeWebView mWebView;

    @FragmentArg("url")
    String url;

    private WebViewManager mWebViewManager;
    private LPAPI mPrinter;

    @AfterViews
    void initView() {
        mWebViewManager = new WebViewManager(getActivity(), mWebView);
        mWebViewManager.loadUrl(url);
    }

    @Override
    public void onResume() {
        super.onResume();
        if (mWebViewManager != null) {
            mWebViewManager.resume();
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        if (mWebViewManager != null) {
            mWebViewManager.pause();
        }
    }

    @Override
    public void onDestroy() {
        if (mWebViewManager != null) {
            mWebViewManager.destroy();
            mWebViewManager = null;
        }
        super.onDestroy();
    }
}
